package com.bangdao.app.jetpacktest.jetpack.livedata;

import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.bangdao.app.jetpacktest.jetpack.viewmodel.NormalTimerActivity;
import com.bangdao.app.jetpacktest.jetpack.viewmodel.TimerActivity;
import com.blankj.utilcode.util.ActivityUtils;

public class LiveDataListActivity extends ListActivity {

    private String[] data = {"ViewModel+LiveData计时器", "ViewModel+LiveData实现Fragment间通信"};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        ArrayAdapter arrayAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, data);
        setListAdapter(arrayAdapter);
    }

    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);

        switch (data[position]){
            case "ViewModel+LiveData计时器": ActivityUtils.startActivity(TimerWithLiveDataActivity.class);
                break;
            case "ViewModel+LiveData实现Fragment间通信": ActivityUtils.startActivity(LiveDataProgressActivity.class);
                break;
        }
    }
}